/*
 * main.cpp
 *
 *  Created on: 29.09.2012
 *      Author: Wolfgang Engelhard
 *
 * Copyright: (c) 2011 by Wolfgang Engelhard
 * License: GNU GPL v2 (see License.txt)
 */
#include <cstdio>
#include <cstring>
#include "lusb0_usb.h"

#include "uhfRadio.h"
#include "usb.h"

using namespace std;



int main(int argc, char **argv) {
	usb_dev_handle *devUhfRadio = 0;
	uint16_t value[2];

	devUhfRadio = openUsbDevice(VENDOR_ID, PRODUCT_ID, PRODUCT_NAME);

	if (devUhfRadio) {
		printf("Established connection to UHF-Radio\n");
		if (argc > 2) {
			if (convert(value, argv[1], argv[2])) {
				printf("Error: converting input data failed\n");
			} else {
				sendData(devUhfRadio, USB_DATA_TX, value);
			}
		} else {
			printf("Error: no arguments provided\n");;
		}
		usb_close(devUhfRadio);
		printf("Connection terminated\n");
	} else {
		printf("Error: USB device handle invalid\n");;
	}

	return 0;
}

